package crack.lshape.mesh7;

import java.io.IOException;

import math2.MathUtilities;
import crack.AbstractLshapeUsingSDAElementDemo;
import fem2.AbstractStructuralCrackDemo;
import fem2.Element;
import fem2.MaterialModel;
import fem2.Mesh;
import fem2.MeshGenerator;
import fem2.MeshPart;
import fem2.Model;
import fem2.element.crack_sda.KOSConstantJumpCSTElement;
import fem2.material.cohesive_law.CohesiveLaw;
import fem2.material.cohesive_law.NoncohesiveLaw;
import fem2.pre_and_post.GidMeshGenerator;

public class LshapeMesh7KOSConstantJumpCSTElementAndNoncohesiveLaw extends
		AbstractLshapeUsingSDAElementDemo {

	public LshapeMesh7KOSConstantJumpCSTElementAndNoncohesiveLaw() {
		meshFileName = "mesh7-kos-none.msh";
	}

	@Override
	public Mesh createMesh() {
		String fn = projectDir + '/' + projectName + '/' + meshFileName;
		MeshGenerator mg = new GidMeshGenerator(fn);
		Mesh mesh = mg.getMesh(2);
		return mesh;
	}

	@Override
	public CohesiveLaw createCohesiveLaw(Model m) {
		double ft = 2.7;
		double Gf = 0.065;
		return new NoncohesiveLaw(Gf, ft);
	}

	@Override
	public Element createElement(MeshPart mp, MaterialModel mm, CohesiveLaw cl) {
		Element e = new KOSConstantJumpCSTElement(mp, mm, cl);
		return e;
	}

	public static void main(String[] args) throws IOException {

		AbstractStructuralCrackDemo sample = new LshapeMesh7KOSConstantJumpCSTElementAndNoncohesiveLaw();

		// double[] lambda = MyLinAlg.createLambdaArray(13.6, 0.1, 13.7);
		// double[] lambda = MyLinAlg.createLambdaArray(13.6, 0.1, 30);
		double[] lambda = MathUtilities.createLambdaArray(13.6, 0.1, 40); // acceptable
																			// result

		sample.run(lambda);

	}
}
